package www.game._04_sum;

public class Sum {
    public static void main(String[] args) {
        double dogePrice = 0.338;
        double doge3LPrice = 1.35;
        // 假设
        System.out.println(getPrice(0.4));
        System.out.println(getPrice(0.5));
        System.out.println(getPrice(0.6));
        System.out.println(getPrice(0.7));
    }

    private static double getPrice(double doge) {
        double dogePrice = 0.338;
        double doge3LPrice = 1.35;
        double percent = (doge - dogePrice) / dogePrice * 3;
        return doge3LPrice * (1 - percent);
    }

    public int GetSum(int a, int b) {
        if (a == b) {
            return a;
        }
        if (a == 0) {
            return getSum(b);
        }
        if (b == 0) {
            return getSum(a);
        }
        int absA = Math.abs(a);
        int absB = Math.abs(b);
        int max, min;
        boolean maxPo, minPo;
        if (absA > absB) {
            max = a;
            min = b;
            maxPo = a > 0;
            minPo = b > 0;
        } else {
            min = a;
            max = b;
            minPo = a > 0;
            maxPo = b > 0;
        }
        int minSum = getSum(min);
        int maxSum = getSum(max);
        if (maxPo ^ minPo) {
            return maxSum + minSum;

        } else {

            return maxSum - minSum + min;
        }

    }

    private int getSum(int num) {
        if (num == 0) {
            return 0;
        }
        if (num > 0) {
            return (1 + num) * num / 2;
        }
        return (num - 1) * -num / 2;
    }
}